﻿using System;
using System.Collections.Generic;
using Sustainalytics.Entities.ConnectionStrings;
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Options;
using MongoDB.Bson.Serialization.Serializers;


namespace Sustainalytics.PregenerateScreeningReports
{
    public class ScreeningToolReportDistributionSession
    {


        static ScreeningToolReportDistributionSession()
        {
            if (!BsonClassMap<ScreeningToolReportDistributionSession>.IsClassMapRegistered(typeof(ScreeningToolReportDistributionSession)))
            {
                var dic = new DictionaryInterfaceImplementerSerializer<Dictionary<ConnectionStringType, string>>(DictionaryRepresentation.ArrayOfDocuments);
                dic.WithKeySerializer(new EnumSerializer<ConnectionStringType>());
                BsonClassMap.RegisterClassMap<ScreeningToolReportDistributionSession>(cm =>
                {
                    cm.AutoMap();
                    cm.MapMember(d =>d.ConnectionStrings).SetSerializer(dic);
                });
            }
        }       


        public class MachineData
        {
            public string MachineId { get; set; }
            public Guid[] ReportIds { get; set; }
            public int TTLMinutes { get; set; }
        }

        public Guid Id { get; set; }
        public DateTime Date { get; set; }
        public bool Completed { get; set; }
        public IEnumerable<MachineData> Machines { get; set; }
        public Dictionary<ConnectionStringType, string> ConnectionStrings { get;set; }
        public string MainMachine { get; set; }
    }

}
